#ifndef HIGHSCORE_H
#define HIGHSCORE_H

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <algorithm>
#include <ios>
#include <cstring>
#include <string>
#include "Constants.h"

#define NUM_HIGH_SCORES 5
#define STRING_BUF_LEN 100

typedef struct {
    int score;
    std::string name;
    std::string replay;
} ScoreEntry;

typedef std::vector<ScoreEntry> ScoreVector;
typedef std::map<std::string, ScoreVector> ScoreMap;

class HighScore
{
    public:
        HighScore(void);
       ~HighScore(void);
       
        bool isHighScore(std::string value, int score);
        bool addNewScore(std::string value, int score, std::string name, std::string replay);
        ScoreVector *getScoreSet(std::string scenario);
        void setScores(std::string scenario);
        void changeScoreEntry(std::string nameLabel, std::string scoreLabel, std::string name, int score);
		std::string getTopScore(std::string scenario);
		std::string getTopScoreReplay(std::string scenario);
		std::string formatScore(int score);
		void setReplays(std::string level);
		void enableReplay(std::string replayLabel, std::string replay);
		void disableReplay(std::string replayLabel);
		std::string getRanking(int score);
		std::string getRankingColour(int score);
        
    private:
        void readFromFile(std::string);
        void initialiseNewHighScores();
        void parseLine(char *);
        void saveToFile(std::string);

        std::string currentFile;
        ScoreMap scoremap;
};

bool compareScoreEntries(ScoreEntry x, ScoreEntry y);

#endif
